package ControlLayer;
import java.util.ArrayList;
import ModelLayer.Person;
import ModelLayer.AddressBook;

/**
 * Controller class for the address book
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 */
public class AddressCtr
{ 
    //declare instance variables to reference containers
    private AddressBook addressBook;
    
    public AddressCtr()
    {
        addressBook = AddressBook.getInstance();
    }
    
    //Dummy implementation: after implementing the model layer 
    //objects of class Person are to be returned, not String
    public Person getPerson(String search)
    {   
        return addressBook.getPerson(search);
    }
    
    public void addPerson(String name, String address, String city, long id, String phone, String zipCode)
    {
       addressBook.addPerson(name, address, city, id, phone, zipCode);
    }
    
    public void deletePerson(String search)
    {
        //search for the person and delete the object from the container
        addressBook.deletePerson(search);
    }
    
    public void updatePerson(String search, String name, String address, String zipCode, String city, String phone, long id)
    {
        addressBook.updatePerson(search, name, address, city, id, phone, zipCode);
    }
    
    public ArrayList listAllPersons()
    {
          return addressBook.listAllPersons();
    }
}
